<template>
	<view>
		<view class="com-ul">
			<view class="com-li" v-for="(item, index) in visite_list" :key="index">
				<view class="cutomer-name clearfix">
					<view class="float_left ellipsis">
						<u-icon margin-left="10" name="account-fill" label-size="24" label-color="#FB5904" :label="item.name" color="#FB5904" size="28"></u-icon>
					</view>
					<view class="float_right staff-name">
						{{ staff_name}}
						<!-- <u-icon name="dianhua" color="#2d73ed" custom-prefix="custom-icon" /> -->
					</view>
				</view>
				<view class="cont">
					<view class="content">{{ item.content }}</view>
					<view v-if="item.picture" class="image-view"><image @click="previewImage(item.picture)" :src="item.picture" mode="aspectFill"></image></view>
					<view class="address clearfix">
						<view class="float_left">
							<block v-if="item.location">
								<u-icon name="map-fill" color="#6c6c6c" size="26"></u-icon>
								{{ item.location }}
							</block>
							<text v-else style="color: #999999;">无定位信息</text>
						</view>
					</view>
					<view class="time clearfix">
						<view class="float_left">{{ $u.timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}</view>
						<view v-if="item.managerMobile" class="float_right" @click="callPhone(item.managerMobile)">
							<!-- 	<u-icon @click="goPage(`/pagesT/customer/CommunicationLogsAdd?id=${item.id}`)"
									style="margin-right: 30rpx;" name="edit-pen-fill" color="#2d73ed" /> -->
							客户电话：{{ item.managerMobile }}
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-loadmore :status="load_status" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			id: '',
			staff_name:'',
			visite_list: {},
			load_status: 'nomore',
			page: 1,
			pageSize: 10,
			total: 0
		};
	},
	onLoad(options) {
		this.id = options.id;
		this.staff_name = options.name;
		this.getCustomerVisitInfo();
	},
	onReachBottom() {
		if (this.total / this.pageSize > this.page) {
			this.page += 1;
			this.getCustomerVisitInfo();
		}
	},
	onPullDownRefresh() {
		this.page = 1;
		this.getCustomerVisitInfo();
	},
	methods: {
		previewImage(image) {
			// 预览图片
			uni.previewImage({
				urls: [image],
				longPressActions: {
					itemList: ['发送给朋友', '保存图片', '收藏'],
					success: function(data) {
						console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
					},
					fail: function(err) {
						console.log(err.errMsg);
					}
				}
			});
		},
		getCustomerVisitInfo() {
			this.load_status = 'loading';
			this.$u.api
				.getCustomerVisitInfo({
					staffId: this.id,
					page: this.page,
					pageSize: this.pageSize
				})
				.then(res => {
					uni.stopPullDownRefresh();
					if (this.page === 1) {
						this.visite_list = res.data;
					} else {
						this.visite_list = this.visite_list.concat(res.data);
					}
					this.total = res.pageTotal;
					this.load_status = this.$utils.loadStatus(this.page, this.pageSize, this.total);
				});
		},
	}
};
</script>

<style lang="scss" scoped>
.com-ul {
	.com-li {
		width: 710rpx;
		margin: 20rpx auto;
		background-color: #ffffff;
		padding: 20rpx 0;
		border-radius: 20rpx;

		.cutomer-name {
			padding-bottom: 10rpx;
			color: $uni-color-primary;
			font-size: 24rpx;

			.float_left {
				max-width: 540rpx;
				background-color: #ecf5ff;
				border-top-right-radius: 20rpx;
				border-bottom-right-radius: 20rpx;
				padding: 0 20rpx;
				line-height: 40rpx;
			}

			.staff-name {
				padding-right: 20rpx;
				line-height: 40rpx;
			}
		}

		.cont {
			padding: 0 20rpx;
			line-height: 36rpx;

			.content {
				padding-bottom: 10rpx;
			}

			.image-view {
				padding-bottom: 10rpx;

				image {
					width: 120rpx;
					height: 120rpx;
					border-radius: 10rpx;
				}
			}

			.address {
				padding-bottom: 10rpx;
				font-size: 24rpx;
			}

			.time {
				font-size: 24rpx;
				color: #999999;
			}
		}
	}
}
</style>
